#pragma once

#include "../defines/defines.h"

#define MAXLINES 20
#define SERV   "80"

struct file
{
    char * f_name;      // filename
    char * f_host;      // hostname or IPV4/IPV6 address
    int    f_fd;        // descriptor
    int    f_flags;     // F_XX below

}file[MAXLINES];

#define F_CONNECTING 1  // connect() in progress
#define F_READING    2  // connect complete; now reading
#define F_DONE       3  // all done

#define GET_CMD      "GET %s HTTP/1.0\r\n\r\n"

//   已经连接数目  剩余要连接的数目  剩余要读取的 最大的描述符
int nconn, nfiles, nlefttoconn, nlefttoread, maxfd;

fd_set read_set, write_set;

void home_page(const char *, const char * );
void start_connect(struct file * );
void write_get_cmd(struct file * );


///---------------------lib function-------------------------------------///
struct addrinfo * host_serv(const char * host, const char * serv, int family, int socktype);
